#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <unistd.h>
#include <unordered_map>
#include <algorithm>

using namespace std;


int main()
{
    ifstream ifd("map.txt");
    if(!ifd) return -1;
    unordered_map<string,string> rule;
    string line;
    while(getline(ifd,line)){
        auto it = find(line.begin(), line.end(),' ');
        if(it == line.end()) continue;    
        rule[string(line.begin(),it)]=string(it+1,line.end());
    }
    ifd.close();

    ifstream file("file.txt");
    if(!file) return -1;
    while(getline(file,line)){
        istringstream oss;
        oss.str(line);
        string word;
        while(oss>>word){
            if(rule.find(word)==rule.end()){
                cout<<word<<" ";
            }else{
                cout<<rule[word]<<" ";
            }
        }
        cout<<endl;
    }
    file.close();

    return 0;
}

